<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"  %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'showCart.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    

	
  <script>
  	function modifyProductCount( pid ) {
  	
  		window.open("/WebDemo2/jsp/cart/modify.jsp?pid="+pid  );
  	}
  </script>
  
  </head>
  
  <body>
  		<!-- 
  			演示 window.opener 
  			<input type="text"   id="test" />
  		 -->
  
    	<a href="/WebDemo2/servlet/ProductServlet">继续购物</a>
    	<hr/>
    	<h3>您的购物车</h3>
    	
    	<div align="center" >
    		<span style="background-color: #F7E9F6"> 当前购物车总价 ： </span>
    		<span>
    			<img alt="" src="/WebDemo2/img/money.png"  border="0" height="18px" width="25px">
    			${sessionScope.cart.totalPrice }   元  
    		</span>
    		
    	</div>
    	<br/>
    	
    	
    	<table width="600px"   cellpadding="0"  cellspacing="0" border="0"  align="center">
    		<tr bgcolor="#EBF5F1">
    			<td>商品名称</td>
    			<td>商品价格</td>
    			<td>商品图片</td>
    			<td>商品数量</td>
    			<td>当前总价</td>
    			<td>
    				<a href="servlet/CartServlet?method=clearCart"> 清空购物车</a>
    			</td>
    		</tr>
    		<c:forEach var="item"   items="${sessionScope.cart.items }">
    			<tr bgcolor="#F4F5EB">
    				<td>${item.product.name }</td>
    				<td>${item.product.cost }</td>
    				<td><img src="${item.product.img }"   border="0" /></td>
    				<td>${item.count }</td>
    				<td>${ item.count * item.product.cost  }</td>
    				<td>
    					<a href="javascript:modifyProductCount(${item.product.id }) ">
    						<img  src="/WebDemo2/img/configure.png"  border="0"  width="30px"  height="30px" />
    					</a>
    					
    					<a href="servlet/CartServlet?method=removeProductFromCart&pid=${item.product.id }">
    						<img  src="/WebDemo2/img/delete.png"  border="0"  width="30px"  height="30px" />
    					</a>
    				</td>

    			</tr>
    			
    		</c:forEach>
    	</table>
    	
  </body>
</html>
